package com.wendy.utils.date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.wendy.utils.Constants;
import com.wendy.utils.DateUtil;

import java.io.IOException;
import java.util.Date;

/**
 * @author zhuwending
 */
public class DateTimeJsonSerializer extends JsonSerializer<Date> {
    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(DateUtil.convert2String(date, Constants.YYYY_MM_DD_HH_MM_SS));
    }
}
